import { createSlice } from '@reduxjs/toolkit';

/**store 默认值 */
export interface IInitialState {
  /**用户头像 */
  avatar: string;
  /**角色 */
  role: string;
}

const initialState: IInitialState = {
  /**用户头像 */
  avatar: '',
  /**角色 */
  role: '',
};

const userReducer = createSlice({
  name: 'user.reducer',
  initialState,
  reducers: {
    /**设置头像 */
    setAvatar: (state, action) => {
      state.avatar = action.payload;
    },
    /**设置角色 */
    setRole: (state, action) => {
      state.role = action.payload;
    },
  },
});

export default userReducer;
